<?php
abstract class abstractWidget extends Model
{

    public $registry;
    public $modul_index;
    public $modul_id;
    protected $html = '';
    protected $widget_data;
    private $input_data = null;

    function __construct()
    {
        $this->registry = Registry::getInstance();

        $this->html = '';

        $this->view = $this->registry->get('View');

        $this->modul_index = $this->registry->get('modul_index');
    }

    abstract function process();

    function setInputData($input_data)
    {
        $this->input_data = $input_data;
    }

    function params()
    {
        // берет параметры виджета из базы
    }


    //function getHtml(){
    //    return $this->html;
    //}

    function getWidgetData()
    {
        return $this->widget_data;
    }

    function setWidgetData($data = null)
    {

        if ($data === null) {
            // Для вызова из конкретного виджета
            $name = static::WIDGET_NAME;
            $name = substr($name, 0, -6);

            $q = "SELECT * FROM widgets WHERE widgets_name = '$name' ";
            $r = mysql_query($q);
            if (!$r) return -1;
            if (mysql_num_rows($r) > 0) {
                while ($row = mysql_fetch_assoc($r)) {
                    $this->widget_data = $row;
                }
            }
        } else {
            $this->widget_data = $data;
        }

        return true;

    }

    /*
    static function getInstance(){

        if( !isset(self::$instance) ){
            $className = __CLASS__;
            self::$instance = new $className;
        }
        return self::$instance;

    } // -- getInstance
    */

}